﻿<?php

include_once('./includes.php');

$youremail=$_POST['email'];
$yourpasswd=$_POST['password'];
$realname=$_POST['name'];
$yourgender=$_POST['gender'];

//Array to store validation errors
$errmsg = array();
$errflag = false;

if(isset($_POST['email']) && isset($_POST['gender']) && isset($_POST['name'])){

//email already in DB, return to register page with error prompt
	$checkExist="select * from hs_users where email='$email';";
	$result = mysql_query($checkExist) or die('Error, query failed');
	$row = mysql_fetch_array($result);
	
	if($row>0){
	//header('Location:./register_success.php');
	}
//new user, enter data into database

//fields are not set return to page
}else{
echo "here";
	if(!isset($_POST['email'])){
		$errmsg[] = "请填写Email,将用此Email登陆";
		$errflag = true;
	}
	if(!isset($_POST['name'])){
		$errmsg[] = "请填写真实姓名";
		$errflag = true;
	}
	if(!isset($_POST['gender'])){
		$errmsg[] = "请选择性别";
		$errflag = true;
	}
session_start();
$_SESSION['errmsg'] = $errmsg;
echo "here";
//header('Location:./register.php?msg=error');
}
?>